<?php 

class ContentScopesController extends AppController
{
	var $name = 'ContentScopes';
	var $helpers = array('Index','Form');
	function admin_add()
	{
		$this->pageTitle = __('Add Content Scope');
		$isPopup = false;
		if(isset($this->params['named']['popup']))
		{
			$isPopup = true;
		}
		if($isPopup )
		{
			$this->layout = 'popup';
		}
		if(!empty($this->data))
		{
			if($this->ContentScope->save($this->data))
			{
				if($isPopup ==false)
				{
					$this->successMsg(__('Scope created'));
					$this->redirect(array('action'=>"index"));
				}else
				{
					$this->set('saved',true);
					$this->layout = "ajax";
				}
			}
			else
			{
				if($isPopup ==false)
				{
					$this->errorMsg(__('Unable to create scope.'));
				}
			}
		}
	}
	function admin_index() 
	{
		$this->pageTitle = __('Content Scopes');
		$this->ContentScope->recursive = 0;
		$this->paginate['order'] = array("ContentScope.id");
		$this->paginate['limit'] = 10;
		$this->set('contentScopes', $this->paginate());
	}

	function admin_view($id = null) 
	{
		if (!$id) {
			$this->errorMsg(__('Invalid Content Scope.', true));
			$this->redirect(array('action'=>'index'));
		}
		$this->set('contentScope', $this->ContentScope->read(null, $id));
	}
	function admin_edit($id = null) 
	{
		$this->pageTitle = __('Edit Content Scope');
		if (!$id && empty($this->data)) {
			$this->errorMsg(__('Invalid Content Scope', true));
			$this->redirect(array('action'=>'index'));
		}
		if (!empty($this->data)) {
			if ($this->ContentScope->save($this->data)) {
				$this->successMsg(__('The Content Scope has been saved', true));
				$this->redirect(array('action'=>'index'));
			} else {
				$this->errorMsg(__('The Content Scope could not be saved. Please, try again.', true));
			}
		}
		if (empty($this->data)) {
			$this->data = $this->ContentScope->read(null, $id);
		}
		$this->render('admin_add');
	}

	function admin_delete($id = null) 
	{
		if (!$id) {
			$this->errorMsg(__('Invalid id for Content Scope', true));
			$this->redirect(array('action'=>'index'));
		}
		if ($this->ContentScope->del($id)) {
			$this->successMsg(__('Content Scope deleted', true));
			$this->redirect(array('action'=>'index'));
		}
	}
}

?>